<template>
  <div id="header" class="width-130 mx-auto pt-40 min-height-50 mb-40">
    <span class="text-14 text-black-light3">{{state.detail.createdAt}}</span>
    <p class="text-24 text-black-light2 mt-4 mb-17">{{state.detail.title}}</p>
    <div class="text-black-light3" v-html="state.detail.content"></div>
  </div>
  <ContactUs/>
   <CommonFooter/>
</template>

<script setup>
import { onMounted, reactive, watch } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import urls from '@/api/index'
import CommonFooter from '@/components/CommonFooter.vue'
import ContactUs from '@/components/contactUs.vue'

const router = useRouter()
const state = reactive({
  id: '',
  detail: {}
})
watch(() => router.currentRoute.value.query.id, (newVal) => {
  state.id = newVal
  getDetail()
})
const getDetail = () => {
  urls.news.getDetail(state.id)
    .then((res) => {
      state.detail = res.data
    })
    .catch((err) => {
      ElMessage.error(err.msg)
    })
}
onMounted(() => {
  state.id = router.currentRoute.value.query.id
  const header = document.getElementById('header')
  header.scrollIntoView()
  getDetail()
})
</script>

<style lang="scss" scoped>

</style>
